using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Elo.Exemplo.EFCodeFirst.Domain.Entities;

namespace Elo.Exemplo.EFCodeFirst.Domain.Mapping
{
	public class RegionMap : EntityTypeConfiguration<Region>
	{
		public RegionMap()
		{
			// Primary Key
			this.HasKey(t => t.RegionID);

			// Properties
			this.Property(t => t.RegionID)
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
				
			this.Property(t => t.RegionDescription)
				.IsRequired()
				.IsFixedLength()
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("Region");
			this.Property(t => t.RegionID).HasColumnName("RegionID");
			this.Property(t => t.RegionDescription).HasColumnName("RegionDescription");
		}
	}
}

